<template>
  <div>
    <div class="bg">
      <div class="bg_group">
        <img src="../assets/bg02.png" alt="">
        <img src="../assets/bg03.png" class="bg_line" alt="">
        <img src="../assets/bg04.png" alt="" class="bg_planet"> 
      </div>
    </div>
    <div class="title">
      生成操作票一览
    </div>
    <div>
      <div class="content_box" v-loading="show" element-loading-text="拼命加载中"
      element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)">
        <div class="content_size">
          共生成 <span class="number">{{length}}</span> 个操作票文件
        </div>
        <table class="content_list">
          <template v-for="(item, index) in list" >
            <tr :key="index" v-if="index % 2 == 0" class="tr">
              <td class="left"><span @click="gotoFilePage($event)">{{list[index]}}</span></td>
              <td class="right" v-if="index + 1 < list.length"><span @click="gotoFilePage($event)">{{list[index+1]}}</span></td>
            </tr>
          </template>
        </table>
      </div>
    </div>
    <div @click="gotoPrint" class="btn">一键打印</div>
  </div>
</template>
<script>

export default {

  data() {
    return {
      list: [],
      length: 0,
      fullscreenLoading: false,
      show: true //默认loading加载
    }
  },
  mounted() {
    this.getList()
  },

  methods: {
    getList() {
      // 进入这个页面就开始请求接口，因为图片已经识别成功了，所以不需要再判断其他的
      this.axios({
        url: "http://localhost:8091/listAllTicket?path=resultwords",
        method: "get"
      }).then(res => {
        this.show = false //获取数据成功后结束loading
        this.list = res.data;          
        this.length = this.list.length;       
      })
      .catch(e=>{
        console.log(e)
      })
    },
    gotoFilePage(e) {
      console.log(e.target.innerText)
      var fileName = e.target.innerText
      this.$router.push({path:'/file',query: {fileName: fileName}})
    },
    gotoPrint() {
      this.axios({
        url: "http://127.0.0.1:8091/print",
        method: "get"
      }).then(res => {
             
      })
      .catch(e=>{
        console.log(e)
      })
    }
  }
}
</script>
<style lang="scss" scoped> 
  .bg {
    z-index: -1;
    background:url("../assets/bg01.png") no-repeat;
    background-size:cover;
    background: #011520;
    width:100%;
    height:100%;
    position:fixed;
    margin-top: -8px;
    margin-left: -8px;
    .bg_line {
      position: absolute;
      bottom: 0;
      right: 0;
    }
    .bg_planet {
      position: absolute;
      top: 30px;
      right: 30px;
    }
    
  }
  .title {
    font-size: 48px;
    color: #B8F0FB;
    display: flex;
    justify-content: center;
    padding: 50px 0;
  }
  .content_box {
    white-space:nowrap;/* 不换行 */
    overflow:hidden;
    /* 超出指定区域显示滚动条 */
    overflow: auto;
    background: rgba(62,131,228, 0.1);
    width: 60%;
    height: 650px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    border: 1px solid #3E83E4 !important;
    color: white;
    .content_size {
      margin-top: 20px;
      margin-left: 20px;
      font-size: 28px;
      margin-bottom: 10px;
      .number {
        font-size: 32px;
      }
    }
    .content_list {
      margin-left: 35px;
      font-size: 25px;
      padding: 10px 0;
      .left {
        padding: 10px 0;
      }
      .right {
        position: absolute;
        left: 700px;
        padding: 10px 0;
      }   
    }    
  }
  .btn {
    color: white;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 120px;
    background: #3E83E4;
    width: 400px;
    height: 50px;
    font-size: 23px;
    text-align: center;
    line-height: 50px;
    border-radius: 3px;
  }
</style>